package com.mymarkdown.app.config;

import com.mymarkdown.app.websocket.handler.SelectiveMessageHandler;
import com.mymarkdown.app.websocket.interfaces.HandlerMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

import java.util.List;

/**
 * @author zenglun
 * @date 2021/12/5 7:29 下午
 * @description: TODO
 */
@Configuration
public class WebSocketBeanConfig {

    @Autowired
    private List<HandlerMessage> handlerMessageList;

    @Bean
    public SelectiveMessageHandler selectiveMessageHandler(){
        SelectiveMessageHandler handler = SelectiveMessageHandler.getSelf();
        handler.setHandlerMessages(handlerMessageList);
        return handler;
    }

    @Bean
    public ServerEndpointExporter serverEndpointExporter(){
        return new ServerEndpointExporter();
    }


}
